<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
 	String path=request.getContextPath();// path=/jsp20
 	String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>"/><!--base url  -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> </title>
<script type="text/javascript" src="<%=basePath%>js/jquery-1.8.0.min.js"></script>
</head>
<body>
	<center>
			<span id="msg">&nbsp;</span><br/>
			用户名:<input id="u_name" type="text"><p>
			密码:<input id="pwd" type="text"><p>
			<button id="loginBtn">登录</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" value="注册" onclick="addUser()"/>
	</center>
</body>
<script type="text/javascript">	
	
	$(function(){
		$("#loginBtn").click(function(){
			$.ajax({
				data:{"u_name":$("#u_name").val(),"pwd":$("#pwd").val()},
				type:"post",
				url:"<%=basePath%>Ajaxlogin.do",
				dataType:"json",
				cache:false,//缓存
				success:function(data){
					if(data.result == true){
						alert("成功");
					}else{
						$("#msg").html("登录信息有误");
						$("#msg").css("color","red");
					}
				},
				error:function(){
					alert("失败");
				}
			});
		});
	});
	
	function addUser(){
		location.href="EmpAction/queryDept.do";
	} 
</script>
</html>